package com.webapp.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.webapp.model.ReviewModel;
import com.webapp.model.User;

/**
 * Servlet implementation class ViewUserApp
 */
public class ViewUserApp extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ViewUserApp() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		User user = (User)session.getAttribute("UserObject");
		String theUser = user.getUserName();
		ReviewModel rm = new ReviewModel();
		List apps = (ArrayList)rm.getNeededApplications(theUser);
		session.setAttribute("UserApps", apps);
		RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/viewAppsUser.jsp");
		dispatcher.forward(request, response);
	}

}
